package cn.tedu.appointment.accounts.controller;

import cn.tedu.appointment.accounts.pojo.dto.UserQuery;
import cn.tedu.appointment.accounts.pojo.vo.UserVO;
import cn.tedu.appointment.accounts.service.UserService;
import cn.tedu.appointment.base.response.JsonResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "用户模块")
@RestController
@RequestMapping("/v1/user")
public class UserController {
    @Autowired
    UserService userService;

// 用户列表
    @ApiOperation("用户搜索")
    @GetMapping("select")
    public JsonResult selectAll(UserQuery userQuery){
        log.debug("查询所有用户信息{} userQuery",userQuery);
        List<UserVO> userVO = userService.selectAll(userQuery);
        return JsonResult.ok(userVO);
    }
@ApiOperation("更新用户状态")
    // 更新用户状态(是否拉入黑名单)
    @PostMapping("updateStatus/{id}/{status}")
    public JsonResult updateStatus(@PathVariable Long id, @PathVariable String status){
        log.debug("更新用户状态{}",id+"---"+status);
userService.updateStatus(id,status);
        return JsonResult.ok();
    }
    @ApiOperation("删除用户")
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id) {
        log.debug("删除用户{}", id);
        userService.delete(id);
        return JsonResult.ok();
    }
}
